<?php

namespace app\admin\model\store;

use think\Model;


class Goods extends Model
{

    

    

    // 表名
    protected $name = 'store_goods';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'is_hot_text',
        'type_text',
        'goods_type_text',
        'is_seven_days_text',
        'is_on_sale_text'
    ];
    

    
    public function getIsHotList()
    {
        return ['1' => __('Is_hot 1'), '0' => __('Is_hot 0')];
    }

    public function getTypeList()
    {
        return ['1' => __('Type 1'), '2' => __('Type 2')];
    }

    public function getGoodsTypeList()
    {
        return ['1' => __('Goods_type 1'), '2' => __('Goods_type 2'), '3' => __('Goods_type 3'), '4' => __('Goods_type 4')];
    }

    public function getIsSevenDaysList()
    {
        return ['1' => __('Is_seven_days 1'), '0' => __('Is_seven_days 0')];
    }

    public function getIsOnSaleList()
    {
        return ['1' => __('Is_on_sale 1'), '0' => __('Is_on_sale 0')];
    }


    public function getIsHotTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_hot']) ? $data['is_hot'] : '');
        $list = $this->getIsHotList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getTypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['type']) ? $data['type'] : '');
        $list = $this->getTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getGoodsTypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['goods_type']) ? $data['goods_type'] : '');
        $list = $this->getGoodsTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getIsSevenDaysTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_seven_days']) ? $data['is_seven_days'] : '');
        $list = $this->getIsSevenDaysList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getIsOnSaleTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_on_sale']) ? $data['is_on_sale'] : '');
        $list = $this->getIsOnSaleList();
        return isset($list[$value]) ? $list[$value] : '';
    }




}
